﻿// This File is part of Innovation Foundry's "QualityHelper Project"
//
// Copyright  2009 Innovation Foundry Pty Ltd
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the
// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA  02110-1301 USA
// or alternatively it may be downloaded from <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.Windows.Browser;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace InnovationFoundry.QualityHelper.Silverlight.BLL.Objects
{
    [ScriptableType]
    [DataContract]
    public class ConnectionObject : ISLBLLObject, INotifyPropertyChanged
    {


        private ProcedureObject procedureOrigin;

        public ProcedureObject ProcedureOrigin
        {
            get { return procedureOrigin; }
            set
            {
                if (this.procedureOrigin != value)
                {
                    this.procedureOrigin = value;
                    OnPropertyChanged("ProcedureOrigin");
                }
            }
        }
        private ProcedureObject procedureDestination;

        public ProcedureObject ProcedureDestination
        {
            get { return procedureDestination; }
            set
            {
                if (this.procedureDestination != value)
                {
                    this.procedureDestination = value;
                    OnPropertyChanged("ProcedureDestination");
                }
            }
        }

        private ConnectionTypeObject connectionType;
        public ConnectionTypeObject ConnectionType
        {
            get { return connectionType; }
            set
            {
                if (this.connectionType != value)
                {
                    this.connectionType = value;
                    OnPropertyChanged("ConnectionType");
                }
            }
        }

        public ConnectionObject() { }

        public ConnectionObject(ProcedureObject origin, ProcedureObject destination, ConnectionTypeObject connectionType)
        {
            this.ProcedureOrigin = origin;
            this.ProcedureDestination = destination;
            this.ConnectionType = connectionType;
        }

        /// <summary>
        ///     Called when the value of a property changes.
        /// </summary>
        /// <param name="propertyName">The name of the property that has changed.</param>
        protected virtual void OnPropertyChanged(String propertyName)
        {
            if (String.IsNullOrEmpty(propertyName))
            {
                return;
            }
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        /// <summary>
        ///     Raised when the value of one of the properties changes.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

    }
}
